﻿@model loveMotorcade.web.Models.user

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>user</legend>

        @Html.HiddenFor(model => model.ID)

        <div class="editor-label">
            登录账户
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.name)
            @Html.ValidationMessageFor(model => model.name)
        </div>
        <div class="editor-label">
            访问密码
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.psw)
            @Html.ValidationMessageFor(model => model.psw)
            <button type="button" onclick="getNewPsw()">获取新密码</button>不区分大小写
        </div>
        <div class="editor-label">
             账户简介
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.intro)
            @Html.ValidationMessageFor(model => model.intro)
        </div>


        <div class="editor-label">
           地址
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.address)
            @Html.ValidationMessageFor(model => model.address)
        </div>

        <div class="editor-label">
            地址电话
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.telphone)
            @Html.ValidationMessageFor(model => model.telphone)
        </div>

        <div class="editor-label">
            主要联系人
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.linkman)
            @Html.ValidationMessageFor(model => model.linkman)
        </div>

        <div class="editor-label">
            联系人电话
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.linkphone)
            @Html.ValidationMessageFor(model => model.linkphone)
        </div>

        <div class="editor-label">
            备注(内部)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.bak)
            @Html.ValidationMessageFor(model => model.bak)
        </div>



        <div class="editor-label">
            注销
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.disable)
            @Html.ValidationMessageFor(model => model.disable)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    <script>
        function getNewPsw(){
            var str = "abcdefghijklmnopqrstuvwxyz1234567890";
            var newPsw = "";

            for (var i = 0; i <= 6; i++) {
                
                newPsw += str.charAt(Math.round(Math.random() * (str.length - 1)));
            }
            var rndBg = "rgb(" + Math.round(Math.random() * 255) + "," + Math.round(Math.random() * 255) + "," + Math.round(Math.random() * 255) + ")"

            $("[name='psw']").css("background", rndBg);
            $("[name='psw']").val(newPsw);
        }
        
    </script>
}
